# coding=utf-8

'''
识别网站开发语言，存在误报

ASP.NET
Server:Microsoft-IIS/6.0
Server:Microsoft-IIS/7.5
'''
import requests
import re
from mv import Smmulv
from dosm import DomeSm
class CmsSb(object):

	def __init__(self):
		self.__mu = Smmulv()
		self.__dosm = DomeSm()
	def Cx(self,line,zt):
		'''
		:param line:网站地址
		:param zt: 状态
		:return:
		'''
		head = str(zt.headers)
		#print head
		a = re.search(r'(yunjiasu-nginx|WAF|zhuji.360.cn|yunsuo)',head,re.I)
		if a:
			print '目标网站     '+line+"存在waf   "+a.group()
		else:
			print '目标网站     '+line+'不存在waf'
			self.__dosm.Sm(line)
			self.__mu.Sm(line=line,dic='dict/all.txt')
			b = re.search(r'(PHP|ASP.NET|Servlet|JBoss|Apache-Coyote/1.1)',head,re.I)
			if str(b.group()) == 'PHP':
				print 'PHP'
				self.__mu.Sm(line=line,dic='dict/php.txt')
			if str(b.group()) == 'ASP.NET':
				print 'ASP!!!!'
				#self.__mu.Sm(line=line,dic='dict/asp.txt')
			if str(b.group()) == ('Servlet' and 'JBoss' and 'Apache-Coyote/1.1'):
				print 'jboss-jsp!!!!'
				#self.__mu.Sm(line=line,dic='dict/jsp.txt')

# try:
# 	u = requests.get(url='http://www.test.com',allow_redirects=False,verify=False,timeout=10)
# except Exception,e:
# 	print e
#
# cms = CmsSb()
# cms.Cx(line='http://www.test.com',zt=u)